using UnityEngine;

public class Camshowtime : MonoBehaviour
{
	public Transform target;

	public float distance;

	public float height;

	public float heightDamping;

	public float rotationDamping;

	private float wantedRotationAngle;

	private float wantedHeight;

	private float currentRotationAngle;

	private float currentHeight;

	private Quaternion currentRotation;

	public Transform m_Transform;

	private Vector3 temppos;

	private void Awake()
	{
		m_Transform = base.transform;
	}

	private void LateUpdate()
	{
		Vector3 eulerAngles = target.eulerAngles;
		wantedRotationAngle = eulerAngles.y;
		Vector3 position = target.position;
		wantedHeight = position.y + height;
		Vector3 eulerAngles2 = m_Transform.eulerAngles;
		currentRotationAngle = eulerAngles2.y;
		Vector3 position2 = m_Transform.position;
		currentHeight = position2.y;
		currentRotationAngle = Mathf.LerpAngle(currentRotationAngle, wantedRotationAngle, rotationDamping * Time.deltaTime);
		currentHeight = Mathf.Lerp(currentHeight, wantedHeight, heightDamping * Time.deltaTime);
		currentRotation = Quaternion.Euler(0f, currentRotationAngle, 0f);
		temppos = target.position;
		temppos -= currentRotation * Vector3.forward * distance;
		temppos = new Vector3(temppos.x, currentHeight, temppos.z);
		m_Transform.position = Vector3.Lerp(m_Transform.position, temppos, Time.time);
		m_Transform.LookAt(target);
	}
}
